<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>传智商城</title>
	<link href="/phpkt/g201705.22/shop/Public/css/home.css" rel="stylesheet" />
	<script src="/phpkt/g201705.22/shop/Public/js/jquery.min.js"></script>
</head>
<body>
	<div id="top">
		<div class="top_nav">
		<ul><li>收藏本站</li><li>关注本站</li></ul>
		<ul class="right">
			<li>您好，欢迎来到传智商城！[<a href="#">登录</a>][<a href="#">免费注册</a>]</li>			<li class="line">|</li><li>我的订单</li>
			<li class="line">|</li><li><a href="#" >会员中心</a></li>
			<li class="line">|</li><li><a href="#" >我的购物车</a></li>
			<li class="line">|</li><li>联系客服</li>
		</ul>
		</div>
	</div>
	<div id="box">
		<div id="header">
			<a class="left" href="#"><div id="logo"></div></a>
			<div id="search" class="left">
				<input type="text" class="left" />
				<input class="search_btn" type="button" value="搜索" />
				<p id="search_hot">热门搜索：PHP培训　大学教材　智能手机　平板电脑</p>
			</div>
			<div id="info" class="left">
				<input type="button" value="会员中心" />
				<input type="button" value="去购物车结算" />
			</div>
		</div>
		<div class="clear"></div>
		<div id="nav">
			<ul><li class="category"><a href="#">全部商品分类</a></li><li class="curr"><a href="<?php echo U('Home/Index/index');?>">首页</a></li>
				<li><a href="#">PHP</a></li><li><a href="#">Java</a></li><li><a href="#">安卓</a></li>
				<li><a href="#">.Net</a></li><li><a href="#">C/C++</a></li><li><a href="#">IOS</a></li>
			</ul>
		</div>
<div class="goodsinfo">
	<div class="now_cat">当前位置：
            <?php if(is_array($types)): $i = 0; $__LIST__ = $types;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$to): $mod = ($i % 2 );++$i;?>&nbsp;<a 
		href="#" ><?php echo ($to["cname"]); ?></a>&nbsp;&gt;&nbsp;<?php endforeach; endif; else: echo "" ;endif; ?>    
            <?php echo ($goodsrow["gname"]); ?></div>
	<div class="pic left">		
                <?php if(empty($goodsrow["thumb"])): ?><img src="/phpkt/g201705.22/shop/Public/image/preview2.jpg">
               <?php else: ?>
                   <img src="/phpkt/g201705.22/shop/Public/<?php echo ($goodsrow["thumb"]); ?>"  height='300px' width='260px'><?php endif; ?>
        </div>
	<div class="info left"><h1><?php echo ($goodsrow["gname"]); ?></h1><table>
		<tr><th>售 价：</th><td><span>￥<?php echo ($goodsrow["price"]); ?></span></td></tr>
		<tr><th>商品编号：</th><td><?php echo ($goodsrow["identifier"]); ?></td></tr>
		<tr><th>累计销量：</th><td>1000</td></tr>
		<tr><th>评 价：</th><td>1000</td></tr>
		<tr><th>配送至：</th><td>北京（免运费）</td></tr>
		<tr><th>购买数量：</th><td>
			<input type="button" value="-" class="cnt-btn" />
			<input type="text" value="1" id="num" class="num-btn" />
			<input type="button" value="+" class="cnt-btn" />（库存：<?php echo ($goodsrow["stock"]); ?>）</td></tr>
		<tr><td colspan="2" class="button"><a href="#">立即购买</a><a href="#" onclick="addCart()">加入购物车</a></td></tr>
		</table></div><div class="clear"></div>
	<div class="slide left">相关商品</div>
	<div class="desc left">
		<div class="attr"><p>商品属性</p>
                    <ul>
                    <?php if(is_array($attr)): $i = 0; $__LIST__ = $attr;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li><?php echo ($vo["aname"]); ?>：<?php echo ($vo["avalue"]); ?></li><?php endforeach; endif; else: echo "" ;endif; ?>
                        <div class="clear"></div>
                    </ul></div>
	</div>
	<div class="clear"></div>
</div>
<script>
	//购买数量加减
	$(".cnt-btn").click(function(){
		var num = parseInt($("#num").val());
		if ($(this).val() === '-') {
			if ( num=== 1) return;
			$("#num").val(num-1);
		}else if ($(this).val() === '+') {
			if (num === 100) return;
			$("#num").val(num+1);
		}
	});
	//自动纠正购买数量
	$("#num").keyup(function(){
		var num = parseInt($(this).val());
		if(num<1){ 
			$(this).val(1);
		}else if(num > 100){
			$(this).val(100);
		}
	});
	//添加购物车
	function addCart(){
		var num = $("#num").val();
		window.location.href = '#'+num;
	}
</script>
		<div id="service">
			<ul><li>购物指南</li><li>配送方式</li><li>支付方式</li>
				<li>售后服务</li><li>特色服务</li><li>网络服务</li>
			</ul>
			<div class="clear"></div>
		</div>
		<div id="footer">传智商城·本项目仅供学习使用</div>
	</div>
</body>
</html>